import QtQuick 2.0
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import QtQml.Models 2.2
import "../js/goodsEdit.js" as Ge
import "../lib"
FView {
    id: root
    property var modelData

    function modify(){
        Ge.edit()
    }

    function initialize() {
        Ge.initialize();
    }
    ListModel {
        id: libBrands
    }


    Column {
        anchors.top: parent.top
        anchors.topMargin: 18 * __factor__
        spacing: 18 * __factor__

        FTextField {
            title: "标题"
            id: txtTitle
            height: 96 * __factor__
            width:  root.width / 3 * 2
            anchors.horizontalCenter: parent.horizontalCenter

        }
        FTextField {
            title: "分类"
            id: txtCategory
            height: 96 * __factor__
            width:  root.width / 3 * 2
            anchors.horizontalCenter: parent.horizontalCenter
            iconSource: "../image/fi-page-add-512px.svg"
            onClicked:  Ge.selectCategory()
            property string category_id
        }

        FComboBox {
            title: "品牌"
            id: txtBrands
            indicatorText: "选择"
            height: 96 * __factor__
            width:  root.width / 3 * 2
            anchors.horizontalCenter: parent.horizontalCenter
            textRole: "Name"
            model: libBrands
        }

        FSpinBox {
            id: spkucun
            height: 96 * __factor__
            width:  root.width / 3 * 2
            title: "库存"

            suffix: "件"
            maximumValue: 999999
            anchors.horizontalCenter: parent.horizontalCenter
        }

        FSpinBox {
            id: spprice
            title: "单价"
            height: 96 * __factor__
            width:  root.width / 3 * 2
            suffix: "元"
            anchors.horizontalCenter: parent.horizontalCenter
            maximumValue: 999999.9
            decimals: 1
        }

        FSwitch {
            id: showcase
            title: "橱窗展示"
            height: 96 * __factor__
            width:  root.width / 3 * 2
            anchors.horizontalCenter: parent.horizontalCenter
        }

        FTextArea {
            id: txtDescription
            width:  root.width / 3 * 2
            height:  210 * __factor__
            anchors.horizontalCenter: parent.horizontalCenter
        }


        Item {
            height: 230 * __factor__
            width:  root.width / 3 * 2
            anchors.horizontalCenter: parent.horizontalCenter
            FGroupBox {
                title: "图片"
                anchors.fill: parent

                FImageList {
                    id: imagelist
                    width:  root.width / 3 * 2
                    height: 210 * __factor__
                    onCameraCaptureTriggered: Ge.cameraCaptureTriggered()
                    onFileSelectedTriggered: Ge.fileSelectedTriggered()
                }
            }
        }

        FCustomProperty {
            id: fc
            height: 320 * __factor__
            anchors.horizontalCenter: parent.horizontalCenter
            width:  root.width / 3 * 2
        }

        Item {
            width: root.width
            height: 32 * __factor__
        }
    }
}
